#ifndef OFFLINE_PROCESSOR_H
#define OFFLINE_PROCESSOR_H

#include <libplayerc++/playerc++.h>
#include <string>
#include <path_planning/topological_map.h>

struct Cell {
  int column;
  int row;
  int status;
  int associated_vertex_id;
  int vertex_id;
};

class GridMap {
public:
  GridMap(MapProxy *mapproxy);
  ~GridMap();

  Cell* GetCell(uint32_t column, uint32_t row);

  uint32_t map_width() const;
  uint32_t map_height() const;
  double map_resolution() const;

private:
  Cell **cell_matrix_;

  uint32_t map_width_;
  uint32_t map_height_;
  double map_resolution_;
};

class OfflineProcessor {
public:
  OfflineProcessor(int num_threads);

  void Init(string host_name, int player_port_num, int map_proxy_instance);
  void SetTopologicalMap(string topological_map_file_descriptor);

  // Generates an output file that associates the 'grid_map_' to the 'topological_map_'.
  // The 'Init' and 'SetTopologicalMap' methods must be called prior to this one.
  void Run(string grid_map_path_file);
  void Clear();

private:
  int num_threads_;
  GridMap *grid_map_;
  PlannerMap *topological_map_;
  std::vector<PixelPoint> vertices_;
};

#endif
